package com.example.springboottestgit.service.instruction;

import com.example.springboottestgit.bean.InstructData;
import com.example.springboottestgit.common.RunNum;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @description:
 * @author: ZZZ
 */
@Service
public class Stage2 {
    static int n = 0;

    public List<InstructData> getInstructData() {
        List<InstructData> list = new ArrayList<>();
        for (int i = 1; i <= RunNum.a; i++) {
            //中标公告
            list.add(winTenderNotice(i % 2 == 0));
            //安置残疾人比例
            list.add(placementDisabledPeopleProportion(i % 2 == 0));
        }
        return list;
    }

    //中标公告
    public InstructData winTenderNotice(Boolean b) {
        Random random = new Random();
        //Boolean b = random.nextBoolean();
        int x = 2;
        if (b == true) {
            //x = random.nextInt(40) + 1;
            n++;
            x = n;
            if (n == 16) {
                n = 0;
                x = 1;
            }
        }

        String sign = x == 2 ? "符合" : "不符合";

        String instruction = "中标人确定之日起x个工作日内，采购人或者采购代理机构将在招标文件载明的指定媒体以中标公告的形式发布中标结果是否符合法律法规";
        String input = "";
        String output = "#。根据《中华人民共和国政府采购法实施条例》第四十三条规定，采购人或者采购代理机构应当自中标、成交供应商确定之日起2个工作日内，发出中标、成交通知书，并在省级以上人民政府财政部门指定的媒体上公告中标、成交结果，招标文件、竞争性谈判文件、询价通知书随中标、成交结果同时公告。";

        instruction = instruction.replace("x", x + "");
        output = output.replace("x", x + "").replace("#", sign + "");

        InstructData instructData = new InstructData();
        instructData.setInstruction(instruction);
        instructData.setInput("");
        instructData.setOutput(output);
        return instructData;
    }


    static int disabledPeopleN = 0;

    //安置残疾人比例
    public InstructData placementDisabledPeopleProportion(Boolean b) {
        Random random = new Random();
        int x = random.nextInt(25) + 1;
        if (b == true) {
            x = random.nextInt(30) + 25;
        }

        String sign = x >= 25 ? "符合" : "不符合";

        String instruction = "安置的残疾人占本单位在职职工人数的比例不低于x%是否符合法律法规";
        String input = "";
        String output = "#。根据《残疾人就业条例》的相关规定，对于集中使用残疾人的用人单位，其中从事全日制工作的残疾人职工，应当占本单位在职职工总数的25%以上。因此案例中安置的残疾人占本单位在职职工人数的比例不低于x%#法律法规";

        instruction = instruction.replace("x", x + "");
        output = output.replace("x", x + "").replace("#", sign + "");

        InstructData instructData = new InstructData();
        instructData.setInstruction(instruction);
        instructData.setInput("");
        instructData.setOutput(output);
        return instructData;

    }


}
